package com.example.myapplication;

import android.content.Intent;
import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class BookHomepage extends AppCompatActivity {
    ConstraintLayout layoutAllBooks ,layoutPeopleCount,layoutAddBook , layoutAddReader ,layoutBorrowBook;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.book_homepage_activity);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
        // 初始化视图
         layoutAllBooks = findViewById(R.id.layout_all_books);
        layoutPeopleCount = findViewById(R.id.layout_people_count);
         layoutAddBook = findViewById(R.id.layout_add_book);
         layoutAddReader = findViewById(R.id.layout_add_reader);
         layoutBorrowBook = findViewById(R.id.layout_borrow_book);

        // 设置点击监听器
        layoutAllBooks.setOnClickListener(v -> {
            // 跳转到全部书籍页面
            Intent intent = new Intent(BookHomepage.this, Books_Activity.class);
            startActivity(intent);
        });

        layoutPeopleCount.setOnClickListener(v -> {
            // 跳转到在馆人数页面
            Intent intent = new Intent(BookHomepage.this, Reader_Activity.class);
            startActivity(intent);
        });

        layoutAddBook.setOnClickListener(v -> {
            // 跳转到添加图书页面
            Intent intent = new Intent(BookHomepage.this, AddBookActivity.class);
            startActivity(intent);
        });

        layoutAddReader.setOnClickListener(v -> {
            // 跳转到添加读者页面
            Intent intent = new Intent(BookHomepage.this, AddReaderActivity.class);
            startActivity(intent);
        });

        layoutBorrowBook.setOnClickListener(v -> {
            // 跳转到借阅书籍页面
            Intent intent = new Intent(BookHomepage.this, Borrow_books_Activity.class);
            startActivity(intent);
        });
    }
}